<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<% 
response.setHeader("Pragma","No-cache"); 
response.setHeader("Cache-Control","no-cache"); 
response.setDateHeader("Expires", 0); 
%> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>资方数据统计</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 60px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    </style>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                
	             <div class="fieldBox ">
	                <div class="label">日期:</div>
	                <div class="field">
	                	<input name="crtTmStart" id="crtTmStart" type="text" class="ui-datepicker" validate="{required:true}" value="" ligerui="width: 115">
	                	至：
	                	<input name="crtTmEnd" id="crtTmEnd" type="text" class="ui-datepicker" validate="{required:true}" value="" ligerui="width: 115">
	                </div>
	            </div>
            	
            <div class="fieldBox">
                <div class="label">资方:</div>
                <div class="field">
                	<input name="accountName" id="accountName" type="text" class="ui-textbox" data-value=" " placeholder="--请选择--" ltype="combobox" value="" ligerui="width: 210">
                    <input name="accountId" id="accountId" type="hidden" value="">
                </div>
            </div> 
                
                
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="expBtn" class="sq-button sq-button-round" onclick="exportexcel();">导出excel</span>
                    <!-- <span id="downExcel" onclick="downExcel()" class="sq-button sq-button-round">导入Excel</span> -->
                </div>
                
                <input name="graphicReportList" id="graphicReportList" type="hidden" value="">
                <input name="accountNamesList" id="accountNamesList" type="hidden" value="">
                
            </div>
        </form>
    </div>
  </div> 
  <div class="Wrapper">
    <!-- 已选资方数据折线图  -->
    <div id="imageDiv" style="float:left;">
    	  <img id="image" src="" > 
    </div>
    <!-- 资方筛选项 -->
    <div  style="float:right;">
    		
               <div class="fieldBox">
               		<div class="label">已选资方当前可用余额：
                         <input name="availableBalance" id="availableBalance" type="text">万元
                    </div>
                </div>
                <div class="fieldBox">
               		<div class="label">该余额可持续放款天数(不计回款)：
                        <input name="balanceCanContinueLoanDays" id="balanceCanContinueLoanDays" type="text">
                    </div>
                </div>
                <div class="fieldBox">
               		<div class="label">该余额可持续放款天数(计入日均回款)：
                        <input name="repayAccountMoney" id="repayAccountMoney" type="text">
                    </div>
                </div>
                <br>
                <br>
                <br>
                <div class="fieldBox">
                	<div class="field">
                        <input name="crtTmStartDes" id="crtTmStartDes" type="text"> ——
                        <input name="crtTmEndDes" id="crtTmEndDes" type="text"> 时间内
                    </div>
                </div>
                <div class="fieldBox">
               		<div class="label">已选资方日均放款：
                        <input name="dailyAverageLoan" id="dailyAverageLoan" type="text">万元
                    </div>
                </div>
                 <div class="fieldBox">
               		<div class="label">已选资方日均回款：
                        <input name="dailyAverageReturn" id="dailyAverageReturn" type="text">万元
                    </div>
                </div>
                
              
    </div>
</div>

备注:以上数据包含资方有： <p id="accountNamesDesc"></p>
<script type="text/javascript">
	var form=null,formData=null, data=null,graphicReportList=null,accountNamesList=null;
    $(function () {
    	//初始化资方机构名称
    	initAccount();
    	//初始化基础数据
    	init();
    	/* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });

        /* 查询 */
        $("#searchBtn").click(function (event) {
        	init();
        });
        
    });
    
  //资方机构
	function initAccount(){
		$("#accountName").ligerComboBox({ 
			url: '<%=path%>/mcr/mcrGraphicReport/getAccount.do',
			ajaxType :'GET',
            slide: false,
            selectBoxHeight: 200,
            valueField: 'key', 
            textField: 'value',
            isMultiSelect: true
        });
		//下拉框赋值
		var _accountId = $("#accountName").val();
		if(_accountId != ""){
			liger.get("accountId").setValue(_accountId);
		}
	}
  
  
	function init(){
		graphicReportList = null;
   	 	form = $("#searchBar").ligerForm();
        formData = form.getData();
        console.log("formData>>"+JSON.stringify(formData));
   		$.ajax({
			type: 'get',
			dataType:'json',
			async:false,
			data :formData,
			url: '<%=path%>/mcr/mcrGraphicReport/statisticsOfManagementData.do',
			beforeSend:function(){
                wait_dialog=$.ligerDialog.SQalert({content: '生成折线图中....',SQ_type: "waitting"});
            }, 
			success:function(msg){
				console.log("msg>>"+JSON.stringify(msg));
				 wait_dialog.close();
				 if(msg.success == 1){
                     data = msg.data ;
	                 $('#availableBalance').val(data.availableBalance);//已选资方当前账户余额
	                 $('#balanceCanContinueLoanDays').val(data.balanceCanContinueLoanDays);//该余额可持续放款天数(不计回款)
	                 $('#repayAccountMoney').val(data.repayAccountMoney);//该余额可持续放款天数(计入日均回款)
	                 $('#crtTmStartDes').val(data.crtTmStartDes);//开始日期
	                 $('#crtTmEndDes').val(data.crtTmEndDes);//结束日期
	                 $('#dailyAverageLoan').val(data.dailyAverageLoan);//已选资方日均回款数
	                 $('#dailyAverageReturn').val(data.dailyAverageReturn);//已选资方日均回款
	                 $('#graphicReportList').val(data.graphicReportList);//
	                 $('#accountNamesList').val(data.accountNamesList);//
	                 document.getElementById("accountNamesDesc").innerText=data.accountNamesList;
	                 graphicReportList = data.graphicReportList;
	                 accountNamesList = data.accountNamesList;
	                 
	                 console.log("graphicReportList>>"+JSON.stringify(graphicReportList));
	                 $("#image").attr("src",'<%=path%>/mcr/mcrGraphicReport/openImage.do?graphicReportList='+JSON.stringify(graphicReportList)+'&time='+new Date().getTime());
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
   	
	}
	
    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }
    
    //导出excel
    function exportexcel(){
	     var params = "accountName="+JSON.stringify(accountNamesList)+"&graphicReportList="+JSON.stringify(graphicReportList);
	     window.location.href = '<%=path%>/mcr/mcrGraphicReport/exportexcel.do?' + params;
	}
    
</script>

</body>
</html>
